<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuimini/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>对象模型</legend>
        </fieldset>
    </div>
    <form id="metaObject" class="layui-form" action="" method="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">模型编码</label>
                <div class="layui-input-inline">
                    <input type="text" name="code" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                    <tip>填写自己管理账号的名称。</tip>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">模型名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">视图名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="viewName" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">数据表名</label>
                <div class="layui-input-inline">
                    <input type="text" name="tableName" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">主键字段</label>
                <div class="layui-input-inline">
                    <input type="text" name="pkName" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>

        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">数据库名</label>
                <div class="layui-input-inline">
                    <input type="text" name="dataSource" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否单表</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="isSingle" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否可编辑</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="isCelledit" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否有编号</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="isShowNum" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">是否加载</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="isFirstLoad" lay-skin="switch" lay-text="ON|OFF">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">过滤条件</label>
                <div class="layui-input-inline">
                    <input type="text" name="filter" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">默认排序</label>
                <div class="layui-input-inline">
                    <input type="text" name="defaultOrder" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">自定义卡片</label>
                <div class="layui-input-inline">
                    <input type="text" name="diyCard" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">自定义JS</label>
                <div class="layui-input-inline">
                    <input type="text" name="diyJs" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">定义拦截器</label>
                <div class="layui-input-inline">
                    <input type="text" name="bizIntercept" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-form-item">
                <label class="layui-form-label">视图SQL</label>
                <div class="layui-input-block">
                    <input type="text" name="viewSql" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-form-item">
                <label class="layui-form-label">拓展配置</label>
                <div class="layui-input-block">
                    <input type="text" name="config" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="metaObject"  >立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/layuimini/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>

<script>
    layui.use(['form','jquery'],function () {
        var form = layui.form,
            layer = layui.layer;
        form.render();



        /*form.on('submit(metaObject)',function (data){
        alert(data.field)
        }){
            return false;
        };*/

        form.on('submit(metaObject)',function (data) {
            $.ajax({
                type:'post',
                url:'/metaObject/add',
                data:data.field,  //重点必须为一个变量如：data
                dataType:'json',
                success:function(res){
                    var index = layer.alert(JSON.stringify(res), {
                        title: '最终的提交信息'
                    });

                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.location.reload();
                    parent.layer.close(iframeIndex);
                },
                error:function(){
                    layer.alert(JSON.stringify('失败'));
                }
            });
            return false;
        });

    });
</script>




</body>
</html>